package com.cnebula.openapi.auth.service;

import com.cnebula.openapi.auth.vo.AccessToken;
import com.cnebula.openapi.auth.vo.AuthCode;
import com.cnebula.openapi.auth.vo.User;

import io.vertx.core.Future;

public interface OAuthService {
	
	public static final String PARAMS_RESPONSE_TYPE = "response_type";
	public static final String PARAMS_GANT_TYPE = "gant_type";
	public static final String PARAMS_CLIENT_ID = "client_id";
	public static final String PARAMS_TENANT_ID = "tenant_id";
	public static final String PARAMS_REDIRECT_URI = "redirect_uri";
	public static final String PARAMS_SIGN = "sign";
	public static final String PARAMS_SIGN_METHOD = "sign_method";
	public static final String PARAMS_LP_SIGN = "lp_sin";
	public static final String PARAMS_ACCESS_TOKEN = "access_token";
	public static final String PARAMS_TIMESTAMP = "timestamp";
	
	public static final String RESPONSE_TYPE = "code";
	public static final String GANT_TYPE = "authorization_code";

	/**
	 * 创建授权码
	 * 
	 * @param clientKey
	 * @param tenantId
	 * @param user 用户实体
	 * @param accessToken AccessToken实体
	 * @return 授权码
	 *         
	 */
	public Future<AuthCode> createCode(String clientKey, String tenantId, User user, AccessToken accessToken);
	
	/**
	 * 验证授权码
	 * 
	 * @param code 授权代码
	 * @return AuthCode
	 *         AuthCodeUnavailableException 授权码不可用
	 */
	public Future<AuthCode> checkCode(String code);
	
	/**
	 * 授权
	 * 
	 * @param code 授权码
	 * @return AccessToken
	 *         AuthCodeUnavailableException 授权码不可用
	 */
	public Future<AccessToken> authorize(String code);
	
	/**
	 * 验证access_token合法性
	 * @param token access_token
	 * @return AccessToken
	 *         AccessTokenIllegalException  非法的access token
	 */
	public Future<AccessToken> checkAccessToken(String token);
}
